﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace CIS.Server.EFCore.Migrations
{
    /// <inheritdoc />
    public partial class init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "InlineTools",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    InlineToolId = table.Column<string>(type: "TEXT", nullable: true),
                    InlineType = table.Column<int>(type: "INTEGER", nullable: false),
                    EquipmentMode = table.Column<int>(type: "INTEGER", nullable: false),
                    OperationName = table.Column<string>(type: "TEXT", nullable: true),
                    Status = table.Column<int>(type: "INTEGER", nullable: false),
                    ControlState = table.Column<int>(type: "INTEGER", nullable: false),
                    CommunicationEnable = table.Column<bool>(type: "INTEGER", nullable: false),
                    CommunicationState = table.Column<int>(type: "INTEGER", nullable: false),
                    ShopName = table.Column<int>(type: "INTEGER", nullable: false),
                    AnnealOvenChamberCount = table.Column<int>(type: "INTEGER", nullable: false),
                    BackPatchingGlassLimitCount = table.Column<int>(type: "INTEGER", nullable: false),
                    BackPatchingCstHoldTime = table.Column<int>(type: "INTEGER", nullable: false),
                    RobotFromDKCWaitTime = table.Column<int>(type: "INTEGER", nullable: false),
                    RobotFromCstWaitTime = table.Column<int>(type: "INTEGER", nullable: false),
                    SoftwareVersion = table.Column<string>(type: "TEXT", nullable: true),
                    MergeTurnTimeSet = table.Column<int>(type: "INTEGER", nullable: false),
                    BackPatchingType = table.Column<int>(type: "INTEGER", nullable: false),
                    OperationModeHostValues = table.Column<string>(type: "TEXT", nullable: true),
                    UseOED = table.Column<bool>(type: "INTEGER", nullable: false),
                    OEDOnlyRequest = table.Column<bool>(type: "INTEGER", nullable: false),
                    CanTpHalf = table.Column<bool>(type: "INTEGER", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    CreatorId = table.Column<string>(type: "TEXT", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    LastModifierId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_InlineTools", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Ports",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    PortId = table.Column<string>(type: "TEXT", nullable: true),
                    Name = table.Column<string>(type: "TEXT", nullable: true),
                    QualifiedLocationId = table.Column<string>(type: "TEXT", nullable: true),
                    LocationId = table.Column<string>(type: "TEXT", nullable: true),
                    Status = table.Column<int>(type: "INTEGER", nullable: false),
                    Enable = table.Column<int>(type: "INTEGER", nullable: false),
                    PortUseType = table.Column<int>(type: "INTEGER", nullable: false),
                    PortType = table.Column<int>(type: "INTEGER", nullable: false),
                    TRSMode = table.Column<int>(type: "INTEGER", nullable: false),
                    GetEnable = table.Column<bool>(type: "INTEGER", nullable: false),
                    LotId = table.Column<string>(type: "TEXT", nullable: true),
                    LotPriority = table.Column<int>(type: "INTEGER", nullable: false),
                    LotStatus = table.Column<int>(type: "INTEGER", nullable: false),
                    ProductId = table.Column<string>(type: "TEXT", nullable: true),
                    ProductCategory = table.Column<string>(type: "TEXT", nullable: true),
                    PPID = table.Column<string>(type: "TEXT", nullable: true),
                    OperationId = table.Column<string>(type: "TEXT", nullable: true),
                    UnitPathNo = table.Column<int>(type: "INTEGER", nullable: false),
                    IsTopFirst = table.Column<bool>(type: "INTEGER", nullable: false),
                    IsAutoPutBottomFirst = table.Column<bool>(type: "INTEGER", nullable: false),
                    GetHand = table.Column<int>(type: "INTEGER", nullable: false),
                    WorkOrder = table.Column<string>(type: "TEXT", nullable: true),
                    CassetteId = table.Column<string>(type: "TEXT", nullable: true),
                    RobotName = table.Column<string>(type: "TEXT", nullable: true),
                    BatchType = table.Column<int>(type: "INTEGER", nullable: false),
                    LoadTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    RobotTeachingNo = table.Column<int>(type: "INTEGER", nullable: false),
                    CassetteSequenceNo = table.Column<int>(type: "INTEGER", nullable: false),
                    GlassThickness = table.Column<string>(type: "TEXT", nullable: true),
                    CassetteType = table.Column<int>(type: "INTEGER", nullable: false),
                    UnitId = table.Column<string>(type: "TEXT", nullable: true),
                    CassetteStatus = table.Column<int>(type: "INTEGER", nullable: false),
                    SlotMap = table.Column<string>(type: "TEXT", nullable: true),
                    Capacity = table.Column<int>(type: "INTEGER", nullable: false),
                    IsWIPConcerned = table.Column<bool>(type: "INTEGER", nullable: false),
                    JobExistenceSlot = table.Column<string>(type: "TEXT", nullable: true),
                    SlottoStart = table.Column<string>(type: "TEXT", nullable: true),
                    JobCountinCassette = table.Column<short>(type: "INTEGER", nullable: false),
                    JobCounttoProcess = table.Column<short>(type: "INTEGER", nullable: false),
                    CarrierType = table.Column<string>(type: "TEXT", nullable: true),
                    QTimeCheckFlag = table.Column<bool>(type: "INTEGER", nullable: false),
                    PortGlassType = table.Column<int>(type: "INTEGER", nullable: false),
                    PortProductType = table.Column<int>(type: "INTEGER", nullable: false),
                    PortJudgeGrade = table.Column<int>(type: "INTEGER", nullable: false),
                    BatchGetPriorty = table.Column<int>(type: "INTEGER", nullable: false),
                    BatchPutPriorty = table.Column<int>(type: "INTEGER", nullable: false),
                    RmsScenarioFlag = table.Column<bool>(type: "INTEGER", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    CreatorId = table.Column<string>(type: "TEXT", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    LastModifierId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Ports", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ProcessPrograms",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    PPID = table.Column<string>(type: "TEXT", nullable: true),
                    Name = table.Column<string>(type: "TEXT", nullable: true),
                    Description = table.Column<string>(type: "TEXT", nullable: true),
                    PPChangedInfo = table.Column<int>(type: "INTEGER", nullable: false),
                    OperationMode = table.Column<short>(type: "INTEGER", nullable: false),
                    OperationName = table.Column<string>(type: "TEXT", nullable: true),
                    MixRunFlag = table.Column<bool>(type: "INTEGER", nullable: false),
                    RoutingPPIDName = table.Column<string>(type: "TEXT", nullable: true),
                    AnnealOvenCheckDummyFlag = table.Column<bool>(type: "INTEGER", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    CreatorId = table.Column<string>(type: "TEXT", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    LastModifierId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProcessPrograms", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Recipes",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    SourceId = table.Column<string>(type: "TEXT", nullable: true),
                    RecipeId = table.Column<string>(type: "TEXT", nullable: true),
                    RecipeNo = table.Column<int>(type: "INTEGER", nullable: false),
                    ParentRecipeId = table.Column<string>(type: "TEXT", nullable: true),
                    RecipeLayer = table.Column<string>(type: "TEXT", nullable: true),
                    Description = table.Column<string>(type: "TEXT", nullable: true),
                    CommandCode = table.Column<int>(type: "INTEGER", nullable: false),
                    UserAccount = table.Column<string>(type: "TEXT", nullable: true),
                    Reported = table.Column<bool>(type: "INTEGER", nullable: false),
                    Version = table.Column<string>(type: "TEXT", nullable: true),
                    RecipeType = table.Column<string>(type: "TEXT", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    CreatorId = table.Column<string>(type: "TEXT", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    LastModifierId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Recipes", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SubUnits",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    QualifiedLocationId = table.Column<string>(type: "TEXT", nullable: true),
                    SubUnitId = table.Column<string>(type: "TEXT", nullable: true),
                    Name = table.Column<string>(type: "TEXT", nullable: true),
                    Category = table.Column<int>(type: "INTEGER", nullable: false),
                    Status = table.Column<int>(type: "INTEGER", nullable: false),
                    UnitPathNo = table.Column<int>(type: "INTEGER", nullable: false),
                    Capacity = table.Column<int>(type: "INTEGER", nullable: false),
                    UnitId = table.Column<string>(type: "TEXT", nullable: true),
                    IsWIPConcerned = table.Column<bool>(type: "INTEGER", nullable: false),
                    HostReportFlag = table.Column<bool>(type: "INTEGER", nullable: false),
                    FdcReportFlag = table.Column<bool>(type: "INTEGER", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    CreatorId = table.Column<string>(type: "TEXT", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    LastModifierId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SubUnits", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Units",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    UnitId = table.Column<string>(type: "TEXT", nullable: true),
                    Name = table.Column<string>(type: "TEXT", nullable: true),
                    QualifiedLocationId = table.Column<string>(type: "TEXT", nullable: true),
                    RemainGlass = table.Column<bool>(type: "INTEGER", nullable: false),
                    OperatorId = table.Column<string>(type: "TEXT", nullable: true),
                    Category = table.Column<int>(type: "INTEGER", nullable: false),
                    LinkType = table.Column<int>(type: "INTEGER", nullable: false),
                    Status = table.Column<int>(type: "INTEGER", nullable: false),
                    ConnectionStatus = table.Column<bool>(type: "INTEGER", nullable: false),
                    OperationMode = table.Column<int>(type: "INTEGER", nullable: false),
                    SkipMode = table.Column<string>(type: "TEXT", nullable: true),
                    CurrentRecipeId = table.Column<string>(type: "TEXT", nullable: true),
                    CurrentPPId = table.Column<string>(type: "TEXT", nullable: true),
                    WipCount = table.Column<int>(type: "INTEGER", nullable: false),
                    AutoRecipeChange = table.Column<bool>(type: "INTEGER", nullable: false),
                    UnitPathNo = table.Column<int>(type: "INTEGER", nullable: false),
                    UpstreamUnit = table.Column<string>(type: "TEXT", nullable: true),
                    NotUsePPIDMap = table.Column<bool>(type: "INTEGER", nullable: false),
                    UseDummyRequest = table.Column<bool>(type: "INTEGER", nullable: false),
                    DummyRequestCount = table.Column<int>(type: "INTEGER", nullable: false),
                    UseRecipe = table.Column<bool>(type: "INTEGER", nullable: false),
                    InlineToolId = table.Column<string>(type: "TEXT", nullable: true),
                    CIMMode = table.Column<int>(type: "INTEGER", nullable: false),
                    SoftwareVersion = table.Column<string>(type: "TEXT", nullable: true),
                    OperaMode = table.Column<int>(type: "INTEGER", nullable: false),
                    IndexerOperationMode = table.Column<int>(type: "INTEGER", nullable: false),
                    LoadingStop = table.Column<bool>(type: "INTEGER", nullable: false),
                    JobReserverRequest = table.Column<bool>(type: "INTEGER", nullable: false),
                    UnitOperationChangeable = table.Column<bool>(type: "INTEGER", nullable: false),
                    UnitAliveTimeout = table.Column<int>(type: "INTEGER", nullable: false),
                    FdcReportFlag = table.Column<bool>(type: "INTEGER", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    CreatorId = table.Column<string>(type: "TEXT", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    LastModifierId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Units", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "PPIDMappings",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    PPID = table.Column<string>(type: "TEXT", nullable: true),
                    SourceId = table.Column<string>(type: "TEXT", nullable: true),
                    RecipeId = table.Column<string>(type: "TEXT", nullable: true),
                    BandingRouting = table.Column<bool>(type: "INTEGER", nullable: false),
                    CommandCode = table.Column<int>(type: "INTEGER", nullable: false),
                    LastChangedTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    MixRunFlag = table.Column<bool>(type: "INTEGER", nullable: false),
                    OperationName = table.Column<string>(type: "TEXT", nullable: true),
                    BandingSubUnitNos = table.Column<string>(type: "TEXT", nullable: true),
                    RecipeType = table.Column<int>(type: "INTEGER", nullable: false),
                    RecipeNo = table.Column<int>(type: "INTEGER", nullable: false),
                    RoutingPPID = table.Column<string>(type: "TEXT", nullable: true),
                    ProcessProgramEntityId = table.Column<Guid>(type: "TEXT", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    CreatorId = table.Column<string>(type: "TEXT", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    LastModifierId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PPIDMappings", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PPIDMappings_ProcessPrograms_ProcessProgramEntityId",
                        column: x => x.ProcessProgramEntityId,
                        principalTable: "ProcessPrograms",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "RecipeParameters",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "TEXT", nullable: false),
                    SourceId = table.Column<string>(type: "TEXT", nullable: true),
                    RecipeId = table.Column<string>(type: "TEXT", nullable: true),
                    Name = table.Column<string>(type: "TEXT", nullable: true),
                    Description = table.Column<string>(type: "TEXT", nullable: true),
                    Format = table.Column<string>(type: "TEXT", nullable: true),
                    Length = table.Column<int>(type: "INTEGER", nullable: false),
                    Value = table.Column<string>(type: "TEXT", nullable: true),
                    MinValue = table.Column<string>(type: "TEXT", nullable: true),
                    MaxValue = table.Column<string>(type: "TEXT", nullable: true),
                    PParmType = table.Column<string>(type: "TEXT", nullable: true),
                    CommandCode = table.Column<int>(type: "INTEGER", nullable: false),
                    Reported = table.Column<bool>(type: "INTEGER", nullable: false),
                    Order = table.Column<int>(type: "INTEGER", nullable: false),
                    RecipeEntityId = table.Column<Guid>(type: "TEXT", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    CreatorId = table.Column<string>(type: "TEXT", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    LastModifierId = table.Column<string>(type: "TEXT", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RecipeParameters", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RecipeParameters_Recipes_RecipeEntityId",
                        column: x => x.RecipeEntityId,
                        principalTable: "Recipes",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_PPIDMappings_ProcessProgramEntityId",
                table: "PPIDMappings",
                column: "ProcessProgramEntityId");

            migrationBuilder.CreateIndex(
                name: "IX_RecipeParameters_RecipeEntityId",
                table: "RecipeParameters",
                column: "RecipeEntityId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "InlineTools");

            migrationBuilder.DropTable(
                name: "Ports");

            migrationBuilder.DropTable(
                name: "PPIDMappings");

            migrationBuilder.DropTable(
                name: "RecipeParameters");

            migrationBuilder.DropTable(
                name: "SubUnits");

            migrationBuilder.DropTable(
                name: "Units");

            migrationBuilder.DropTable(
                name: "ProcessPrograms");

            migrationBuilder.DropTable(
                name: "Recipes");
        }
    }
}
